package com.game.worm.mobile.view.message;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.dx.as.ToolBarOptions;
import com.dx.as.UI;
import com.game.worm.mobile.R;
import com.game.worm.mobile.view.message.adpater.MessageAdpater;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by d_xxiang on 2018/3/29.
 */

public class MessageActivity extends UI {
    private TabLayout tabLayout;
    private MessageAdpater adpater;
    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_message);
        initView();
        initToolbar();
    }

    private void initToolbar(){
        ToolBarOptions toolBarOptions = new ToolBarOptions();
        toolBarOptions.showLeftImg = true;
        toolBarOptions.titleId = R.string.message_of_mine;
        setToolbar(toolBarOptions);
    }

    private void initView(){
        tabLayout = findViewById(R.id.tabs);

        String [] titles = getResources().getStringArray(R.array.message_tabs);
        for (int i = 0; i < titles.length; i++){
            tabLayout.addTab(tabLayout.newTab().setText(titles[i]));
        }
        tabLayout.addOnTabSelectedListener(onTabSelectedListener);

        RecyclerView recyclerView = findViewById(R.id.recyclerview);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        adpater = new MessageAdpater(this);
        recyclerView.setAdapter(adpater);
        getTestData();
    }

    private void getTestData(){
        List<MessageBean> list = new ArrayList<>();
        for (int i = 0; i < 5; i ++){
            list.add(new MessageBean());
        }
        adpater.setData(list);
        adpater.notifyDataSetChanged();
    }

    private TabLayout.OnTabSelectedListener onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    };

}
